import express from 'express';
import cookieParser from 'cookie-parser';
import cookieSession from 'cookie-session';
import bodyParser from 'body-parser';
import uuid from 'uuid';
import consolidate from 'consolidate';
import logger from 'morgan';
import { request } from 'https';


let app = express();
app.listen(8080);


app.use(express.static("./public"));
app.use(logger("dev"));
app.use(logger("combined", {
    stream: require("fs").createWriteStream("./logs/logs.log", {
        flags: "a"
    })
}));

//拓展模式

app.use(bodyParser.urlencoded({
    extended: true,
    limit: "500mb"
}));

//支持拓展的格式
app.use(bodyParser.json());
app.use(bodyParser.text());

//配置钥匙
app.use(cookieParser("user.cn"));
app.use(cookieSession({
    genid: function () {
        return uuid.v1()
    },
    secret: "user.cn",
    maxAge: 1000 * 60 * 60
}))

app.set("view engine", 'html');
app.set("views", "./views")
app.engine("html", consolidate.ejs);

//路由

// app.use("/",(request,response,next)=>{
//     response.end("ok")
// })

app.use("/admin", require("./router/admin/adminRouter"))